home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / et / et-2_2.lha / et2.2 / src / SeqColl.h < prev    next >
C/C++ Source or Header  |  1990-11-28  |  2KB  |  59 lines

  1. #ifndef SeqColl_First
  2. #ifdef __GNUG__
  3. #pragma once
  4. #endif
  5. #define SeqColl_First
  6.  
  7. #include "Collection.h"
  8.  
  9. //---- abstract class SeqCollection (sequencable collections) ---------------
  10. //     sequenceable collections have an ordering relation, eg there is a first
  11. //     and last element
  12.  
  13. typedef class SeqCollection *SeqCollPtr;
  14.  
  15. class SeqCollection: public Collection {
  16. protected:
  17.     SeqCollection();
  18.     
  19. public: 
  20.     MetaDef(SeqCollection);
  21.     virtual void AddFirst(ObjPtr);
  22.     virtual void AddLast(ObjPtr);
  23.     virtual ObjPtr RemoveFirst();
  24.     virtual ObjPtr RemoveLast();
  25.     virtual void InsertBefore(ObjPtr before, ObjPtr a);     // abstract
  26.     virtual void InsertAfter(ObjPtr after, ObjPtr a);       // abstract
  27.     virtual void InsertBeforePtr(ObjPtr before, ObjPtr a);  // abstract
  28.     virtual void InsertAfterPtr(ObjPtr after, ObjPtr a);    // abstract
  29.  
  30.     virtual Iterator *MakeReversedIterator(); // abstract
  31.     //---- accessing
  32.     virtual ObjPtr Before(ObjPtr); // abstract
  33.     virtual ObjPtr After(ObjPtr);  // abstract
  34.     virtual ObjPtr First();   // abstract
  35.     virtual ObjPtr Last();    // abstract
  36.     virtual int IndexOf(ObjPtr); // returns -1 if not found, based on IsEqual
  37.     virtual int IndexOfPtr(ObjPtr); // returns -1 if not found, based on identity 
  38.                     // not equality
  39.     int LastIndex()
  40.     { return Size()-1; }
  41. };
  42.  
  43. //---- class RevIter ----------------------------------------------------------
  44.  
  45. class RevIter {
  46.     Iterator *seq;
  47. public:
  48.     RevIter(SeqCollection *col)
  49.     { seq= col->MakeReversedIterator(); }
  50.     ~RevIter()
  51.     { if (seq) delete seq; }
  52.     class Object *operator()()
  53.     { return (*seq)(); }
  54.     void Reset(SeqCollection *col)
  55.     { seq->Reset(col); }
  56. };
  57.  
  58. #endif SeqColl_First
  59.